<link rel="stylesheet" type="text/css" href="../addons/jy_renwu/resource/task.css"/>
<title>任务中心</title>
	<div class="fui-page">
		<div class="fui-header">
            <div class="fui-header-left" ng-click="goback()">
                <a class="back"></a>
            </div>
            <div class="title">任务详情</div>
            <div class="fui-header-right">
            </div>
       </div>
		<div class="fui-content">
			<div class="taskdetail-list">
				<div class="taskdetail-list-media">
					<img src="{{tomedia(pagedata.detail.image)}}"/>
				</div>
				<div class="taskdetail-list-inner">
					<div class="title">{{pagedata.detail.tasktitle}}{{pagedata.detail.title}}</div>
					<span class="text-danger">{{pagedata.desc}}</span>
					<div class="time">
						<!--已接任务-->
						<p ng-if="pagedata.detail.task_demand">领取时间：{{pagedata.detail.picktime}}</p>
						<p ng-if="pagedata.detail.task_demand">截至时间：{{ifelse(pagedata.detail.stoptime=='0000-00-00 00:00:00','无限制',pagedata.detail.stoptime)}}</p>
						<!--未接任务-->
						<p ng-if="!pagedata.detail.task_demand">开放时间：{{pagedata.detail.starttime}}</p>
						<p ng-if="pagedata.detail.task_demand">结束时间：{{pagedata.detail.endtime}}</p>
                        
                                <p ng-if="!pagedata.detail.task_demand && pagedata.stop_limit>0" class="text-danger">限时：限时{{pagedata.detail.stop_limit/3600}}小时</p>
                       
					
					</div>
					
					<!--已接任务-->
					<div ng-if="pagedata.detail.task_demand" class="taskdetail-progress">
						<div class="progress">
							<div class="progress-inner" style="width: {{pagedata.detail.task_progress/pagedata.detail.task_demand*100}}%"></div>
						</div>
						<span class="times">{{pagedata.detail.task_progress}}/{{pagedata.detail.task_demand}}</span>
					</div>
				
				</div>
			</div>







			<!--任务奖励-->

			<div ng-if="pagedata.detail.tasktype!='poster'" class="taskdetail-reward">
				<div>任务奖励</div>
				
				<div ng-if="pagedata.reward.credit1">
					<div class="taskreward">
						<i class="icon icon-jifen"></i>商城积分
						<span class="text-danger">+{{pagedata.reward.credit1}}</span>
					</div>
				</div>
				<div ng-if="pagedata.reward.red">
					<div class="taskreward">
						<i class="icon icon-hongbao"></i>微信红包
						<span class="text-danger">+{{pagedata.reward.red}}</span>
					</div>
				</div>
				
				<div ng-if="pagedata.reward.credit2">
					<div class="taskreward">
						<i class="icon icon-yue"></i>商城余额
						<span class="text-danger">+{{pagedata.reward.credit2}}</span>
					</div>
				</div>
				
				
				
						<div ng-if="pagedata.reward.coupon">
							<a class="taskreward">
								<i class="icon icon-youhuiquan"></i>{{pagedata.reward.coupon.title}}
								<span class="text-danger">x1</span>
							</a>
						</div>
					
			

				
							<div ng-if="pagedata.reward.goods">
								<a class="taskreward taskremark" href="javascript:;" ng-click="access_json('jy_weishop/goods.detail//id='+pagedata.reward.goods.id)">
									<i class="icon icon-shangpin"></i>{{pagedata.reward.goods.title}}（{{pagedata.reward.goods.price}}）
									<span class="text-danger">x{{pagedata.reward.goods.num}}</span>
								</a>
							</div>
				
			
				<!--可直接进入下单-->
			
						<div ng-if="!pagedata.rid">
							<a class="taskreward taskremark"
							   href="javascript:;" ng-click="access_json('jy_weishop/goods.detail//id='+pagedata.reward.goods.id)">
								<i class="icon icon-shangpin"></i>{{pagedata.reward_goods.title}}（{{pagedata.reward_goods.price}}元特价购买权）
								<span class="text-danger">x1</span>
							</a>
						</div>
					
			</div>
    




          
            <!--任务奖励-->
			 
            <div ng-if="pagedata.detail.tasktype=='poster' && pagedata.detail.level1" class="taskdetail-reward">
                <div>达到{{pagedata.detail.level1}}人奖励</div>
         
                <div ng-if="!empty(pagedata.reward1.credit)">
                    <div class="taskreward">
                        <i class="icon icon-jifen"></i>商城积分
                        <span class="text-danger">+{{pagedata.reward1.credit1}}</span>
                    </div>
                </div>
            
              
                <div ng-if="!empty(pagedata.reward1.red)">
                    <div class="taskreward">
                        <i class="icon icon-hongbao"></i>微信红包
                        <span class="text-danger">+{{pagedata.reward1.red}}</span>
                    </div>
                </div>
              
                
                <div ng-if="pagedata.reward1.credit2">
                    <div class="taskreward">
                        <i class="icon icon-yue"></i>商城余额
                        <span class="text-danger">+{{pagedata.reward1.credit2}}</span>
                    </div>
                </div>
          
              
               
                <div ng-if="pagedata.reward1.coupon">
                    <a class="taskreward">
                        <i class="icon icon-youhuiquan"></i>{{pagedata.reward1.coupon.title}}
                        <span class="text-danger">x{{pagedata.reward1.coupon.num}}</span>
                    </a>
                </div>
               

          
                    <div ng-if="pagedata.reward1.goods">
                        <a class="taskreward taskremark" href="javascript:;" ng-click="access_json('jy_weishop/goods.detail//id='+pagedata.reward1.goods.id)">
                            <i class="icon icon-shangpin"></i>{{pagedata.reward1.goods.title}}（{{pagedata.reward1.goods.price}}元特价购买权）
                            <span class="text-danger">x1</span>
                        </a>
                    </div>
      
                <!--可直接进入下单-->
               
                <div ng-if="pagedata.rid && 1==2">
                    <a class="taskreward taskremark"
                       href="javascript:;" ng-click="access_json('jy_weishop/goods.detail//id='+pagedata.reward1.goods.id)">
                        <i class="icon icon-shangpin"></i>{{pagedata.reward.goods.title}}（{{pagedata.reward.goods.price}}元特价购买权）
                        <span class="text-danger">x1</span>
                    </a>
                </div>
               
            </div>
           


            <!--任务奖励-->
            <div ng-if="pagedata.detail.tasktype=='poster' && pagedata.detail.level2 && 1==2" class="taskdetail-reward">
                <div>达到{{pagedata.detail.level2}}人奖励</div>
           
                <div ng-if="pagedata.reward2.credit1">
                    <div class="taskreward">
                        <i class="icon icon-jifen"></i>商城积分
                        <span class="text-danger">+{{pagedata.reward2.credit1}}</span>
                    </div>
                </div>
              
            
                <div ng-if="pagedata.reward2.red">
                    <div class="taskreward">
                        <i class="icon icon-hongbao"></i>微信红包
                        <span class="text-danger">+{{pagedata.reward2.red}}</span>
                    </div>
                </div>
              
               
                <div ng-if="pagedata.reward2.credit2">
                    <div class="taskreward">
                        <i class="icon icon-yue"></i>商城余额
                        <span class="text-danger">+{{pagedata.reward2.credit2}}</span>
                    </div>
                </div>
                
                <div ng-if="pagedata.reward2.coupon">
                    <a class="taskreward">
                        <i class="icon icon-youhuiquan"></i>{{pagedata.reward2.coupon.title}}
                        <span class="text-danger">x{{pagedata.reward2.coupon.num}}</span>
                    </a>
                </div>

              
                <div ng-if="!pagedata.rid && pagedata.reward2.goods">
                    <a class="taskreward taskremark" href="javascript:;" ng-click="access_json('jy_weishop/goods.detail//id='+pagedata.reward.goods.id)">
                        <i class="icon icon-shangpin"></i>{{pagedata.reward2.goods.title}}（{{pagedata.reward2.goods.price}}元特价购买权）
                        <span class="text-danger">x{{pagedata.reward2.goods.num}}</span>
                    </a>
                </div>
        
              
                <!--可直接进入下单-->
              
                <div ng-if="pagedata.rid">
                    <a class="taskreward taskremark"
                       href="javascript:;" ng-click="access_json('jy_weishop/goods.detail//id='+pagedata.reward.goods.id)">
                        <i class="icon icon-shangpin"></i>{{pagedata.reward_goods2.reward_title}}（{{pagedata.reward_goods2.price}}元特价购买权）
                        <span class="text-danger">x1</span>
                    </a>
                </div>
              
            </div>
          


        
            <!--任务奖励
            <div ng-if="pagedata.detail.tasktype=='poster' && pagedata.detail.level3" class="taskdetail-reward">
                <div>达到{{pagedata.detail.level3}}人奖励</div>
                <div ng-if="!empty(pagedata.reward3.credit)">
                    <div class="taskreward">
                        <i class="icon icon-jifen"></i>商城积分
                        <span class="text-danger">+{{pagedata.reward3.credit1}</span>
                    </div>
                </div>
               
             
                <div ng-if="!empty(pagedata.reward3.red)">
                    <div class="taskreward">
                        <i class="icon icon-hongbao"></i>微信红包
                        <span class="text-danger">+{{pagedata.reward3.red}}</span>
                    </div>
                </div>
             
                
                <div ng-if="!empty(pagedata.reward3.credit2)">
                    <div class="taskreward">
                        <i class="icon icon-yue"></i>商城余额
                        <span class="text-danger">+{{pagedata.reward3.credit2}}</span>
                    </div>
                </div>
               
                <div ng-if="!empty(pagedata.reward3.coupon)">
                    <a class="taskreward">
                        <i class="icon icon-youhuiquan"></i>{{pagedata.reward3.coupon.title}}
                        <span class="text-danger">x{{pagedata.reward3.coupon.num}}</span>
                    </a>
                </div>
               

               
                <div ng-if="empty(pagedata.rid) && !empty(pagedata.reward3.goods)">
                    <a class="taskreward taskremark" href="{php echo mobileUrl('goods.detail',array('id'=>{pagedata.goods['id']))}">
                        <i class="icon icon-shangpin"></i>{{pagedata.reward3.goods.title}}（{{pagedata.reward3.goods.price}}元特价购买权）
                        <span class="text-danger">x{{pagedata.reward3.goods.num}}</span>
                    </a>
                </div>
              
                <!--可直接进入下单
               
                <div ng-if="!empty(pagedata.rid)">
                    <a class="taskreward taskremark"
                       href="{php echo mobileUrl('goods.detail',array('id'=>(int){pagedata.goods['reward_data'],'taskrewardgoodsid'=>{pagedata.goods['id']))}">
                        <i class="icon icon-shangpin"></i>{{pagedata.reward_goods3.reward_title}}（{{pagedata.reward_goods3.price}}元特价购买权）
                        <span class="text-danger">x1</span>
                    </a>
                </div>
           
            </div>           
			-->
			<!--关注奖励-->
			<div ng-if="(pagedata.detail.tasktype == 'poster' || pagedata.detail.type == 'poster') && (pagedata.followreward.credit1||pagedata.followreward.red||pagedata.followreward.credit2||pagedata.followreward.coupon)" class="taskdetail-reward">
				<div>关注奖励</div>
				
				<div ng-if="pagedata.followreward.credit1">
					<div class="taskreward">
						<i class="icon icon-jifen"></i>商城积分
						<span class="text-danger">+{{pagedata.followreward.credit1}}</span>
					</div>
				</div>
			
				
				<div ng-if="pagedata.followreward.credit1">
					<div  class="taskreward">
						<i class="icon icon-hongbao"></i>微信红包
						<span class="text-danger">+ {{pagedata.followreward.red}}</span>
					</div>
				</div>
				
				<div ng-if="pagedata.followreward.credit2">
					<div class="taskreward">
						<i class="icon icon-yue"></i>商城余额
						<span class="text-danger">+{{pagedata.followreward.credit2}}</span>
					</div>
				</div>
				<div ng-if="pagedata.followreward.credit1">
					<a class="taskreward">
						<i class="icon icon-youhuiquan"></i>{{pagedata.followreward.coupon.title}}
						<span class="text-danger">+{{pagedata.followreward.coupon.num}}</span>
					</a>
				</div>
			</div>
		
			
			<!--参与记录-->
			
			<div ng-if="pagedata.detail.task_demand && pagedata.detail.tasktype == 'poster' && pagedata.joiner" class="taskrecord"> 
				<div>参与记录</div>
				
				<div ng-repeat="(jk,j) in pagedata.joiner" class="record">
					<div class="record-media">
						<img src="{{tomedia(j.headimg)}}"/>
					</div>
					<div class="record-inner">
						{{j.nickname}}
					</div>
					<div class="record-time">
						{{j.gettime}}
					</div>
				</div>
			
			</div>
			
				<!--按钮-->

				<div ng-if="pagedata.detail.task_demand && pagedata.detail.tasktype == 'poster'" class="mask-btn">			
					<a ng-if="pagedata.detail.finishtime && pagedata.detail.finishtime == '0000-00-00 00:00:00'" class="orange" onclick="$('.mask').show()">查看海报</a>
				<!--	<a ng-if="!empty(pagedata.detail.finishtime) && pagedata.detail.finishtime == '0000-00-00 00:00:00'" class="red" onclick="sendToWechat()">发送到微信</a> 
					<a ng-if="pagedata.detail.finishtime && pagedata.detail.finishtime == '0000-00-00 00:00:00'" class="red" ng-click="pagedata.send(pagedata.img);">发送到微信</a> -->
					
					<a ng-if="!pagedata.detail.finishtime || pagedata.detail.finishtime != '0000-00-00 00:00:00'" class="red external" href="{php echo mobileUrl('task.reward')}">领取奖励</a>
				
				</div>
				<div ng-if="!pagedata.detail.task_demand || pagedata.detail.tasktype != 'poster'" class="mask-btn">					
					<a ng-if="pagedata.detail.type" ng-click="access_json('/pickTask//taskid='+pagedata.detail.id)" class="orange pickit" >接取任务</a>				
					<a ng-if="pagedata.detail.finishtime && pagedata.detail.finishtime > '0000-00-00 00:00:00'" class="red external" href="javascript:;" ng-click="pagedata.getReward(pagedata.detail.id)">领取奖励</a>				
				</div>			
		</div>
	</div>


<!--查看海报遮罩层-->

    <div ng-if="pagedata.detail.task_demand && pagedata.detail.tasktype == 'poster'" class="mask" style="display: none;position: absolute;z-index: 9;background-color: rgba(0,0,0,.6);height: 100%;width: 100%;filter:alpha(opacity=100);">
        <div class="qr" style="width: 280px;height: 441px;background-color: red;margin: 50px auto auto auto;">
            <img src="{{pagedata.img}}" style="width: 100%;height: 100%;" onclick="$('.mask').hide()">
        </div>
    </div>

<script>
scope.pagedata.send=function(img){
	var params={
		data:{'img':img},
		op:'send',
		callback:function(res){
			if(res.ok==1)
			scope.message('发送成功，请在微信公众号中查看');
			else{
				scope.message('发送失败');
			}
		}
	};
	scope.post_json(params);
}
scope.pagedata.getReward=function(detail_id){
	var params={
		data:{'detail_id':detail_id},
		op:'getReward',
		callback:function(res){
			if(res.ok==1)
			scope.message('奖品已发放');
			else{
				scope.message('奖品发送失败');
			}
		}
	};
	scope.post_json(params);
}
var token = window.scope.pagedata.token;
function sendToWechat(img) {//发送到微信
	scope.post_json('jy_renwu/detail/send1/',{'img':img},function(res){
		if (res.ok == 1){
			scope.message('推送成功,请在微信公众号中查看')
		}else{
			scope.message('推送失败,可能长时间未与公众号互动')
		}
    });
}
$('.pickit').click(function () {
	 var id = $(this).data('id');
        if (id != undefined){
			scope.post_json('jy_renwu/pickTask//taskid='+id,{},function(res){
				if (res.ok == 1){
					scope.message('接取成功')
				}else{
					scope.message('接取失败,'+res.message)
				}
			});
		}
})
</script>
